package distribuidos.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import distribuidos.dao.*;
import distribuidos.excepcion.DAOExcepcion;
import distribuidos.modelo.*;

@WebServlet("/SalaServlet")
public class SalaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public SalaServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		RequestDispatcher rd;
		HttpSession session = request.getSession();
				
		String boton=request.getParameter("tipo");
		String nombre=request.getParameter("nombre");
		String tipo_sala=request.getParameter("tipo_sala");
		String horario=request.getParameter("horario");
		int capacidad = Integer.parseInt (request.getParameter("capacidad"));
		String descripcion=request.getParameter("descripcion");

		System.out.println(boton+" "+nombre+ " "+ tipo_sala);

        String mod=request.getParameter("mod");

        if(mod.equals("E")){
        	Sala sala = new Sala();
			 rd = request.getRequestDispatcher("listadoSala.jsp");
			 rd.forward(request, response);
		 }else if(mod.equals("B")){
			 rd = request.getRequestDispatcher("consultas.jsp");
			 rd.forward(request, response);
		 }else {
			 rd = request.getRequestDispatcher("consultas.jsp");
			 rd.forward(request, response);
		 }
        
		request.setAttribute("id", "");
		session.setAttribute("anuncio1", null);
		rd=request.getRequestDispatcher("loguin.jsp");
		rd.forward(request, response);

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
